Skip to content

Improvements to the config parser#43

Merged
hnez merged 6 commits into
forrest-runner:mainfrom
hnez:recursive-merges
Jun 25, 2026
Merged

Improvements to the config parser#43
hnez merged 6 commits into
forrest-runner:mainfrom
hnez:recursive-merges

Conversation

@hnez

@hnez hnez commented Mar 2, 2026

Copy link
Copy Markdown
Member

We had to work around missing support for recursive YAML merges in our serde_yaml* / yaml_serde crates for some time now, by writing the configs in a special way.

Work around that once and for all by just applying merges in a loop until they are all resolved.

Also change some other bits and bobs around the config parsing, while at it.

This PR is based on #42 because that switched from sede_yaml_ng to yaml_serde.

@hnez
hnez requested a review from jluebbe March 2, 2026 12:21
@hnez
hnez force-pushed the recursive-merges branch 2 times, most recently from 9ccee41 to a7f8402 Compare March 3, 2026 06:04
@hnez

hnez commented Mar 24, 2026

Copy link
Copy Markdown
Member Author

Maybe use serde-saphyr instead.

hnez added 4 commits June 25, 2026 08:40
This is similar to how GitLab CI handles reusable YAML snippets and is
(in my opinion) prettier and more flexible than the previous top level
`*_snippet`s (which stay usable for backward compatibility reasons).

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
This allows using snippets like these, which already include `<<` merges:

    machine-small: &machine-small
      setup_template:
        path: /etc/forrest/templates/generic
        parameters:
          RUNNER_VERSION: "2.318.0"
          RUNNER_HASH: "28ed88e4cedf0fc93201a901e392a70463dbd0213f2ce9d57a4ab495027f3e2f"
      base_image: /srv/forrest/images/debian-12-generic-amd64.raw
      cpus: 4
      disk: 16G
      ram: 4G
    machine-medium: &machine-medium
      << : *machine-small
      cpus: 8
      disk: 32G
      ram: 8G

And then using them in e.g. machine definitions, just like one would
expect:

    forrest-test:
      machines:
        test-debian:
          << : *machine-medium
          base_machine: hnez/forrest-images/debian-base

This does not work by default in yaml_serde (0.10) because merges in
mappings are not applied recursively.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
This makes it easier to write tests in the future.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
@hnez
hnez force-pushed the recursive-merges branch from a7f8402 to 65097be Compare June 25, 2026 06:47
hnez added 2 commits June 25, 2026 09:06
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
@hnez
hnez force-pushed the recursive-merges branch from 65097be to 1d642d4 Compare June 25, 2026 07:32
@hnez

hnez commented Jun 25, 2026

Copy link
Copy Markdown
Member Author

Maybe use serde-saphyr instead.

I like the current solution.

a) because it is already there.
b) because making the ignored .* fields work seems easier than with serde-saphyr.

I have decided to merge it as is.

@hnez
hnez merged commit 7a95060 into forrest-runner:main Jun 25, 2026
4 checks passed
@hnez
hnez deleted the recursive-merges branch June 25, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant